package com.cdn.openapi.exeception;

import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import java.util.HashMap;
import java.util.Map;

/**
 * @author 蔡定努
 * @date 2024/08/12 15:18
 */
@RestControllerAdvice
public class GlobalException {


    /**
     * @author 蔡定努
     */
    @ExceptionHandler(SignException.class)
    public Object signErroe(SignException signException) {
        Map<String, Object> map = new HashMap<>();
        map.put("code", HttpStatus.UNAUTHORIZED.value());
        map.put("msg", signException.getMessage());
        return map;
    }
    @ExceptionHandler(AuthException.class)
    public Object auth(AuthException signException) {
        Map<String, Object> map = new HashMap<>();
        map.put("code", HttpStatus.FORBIDDEN.value());
        map.put("msg", signException.getMessage());
        return map;
    }

}
